package com.graph;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Solution1557 {
    public List<Integer> findSmallestSetOfVertices(int n, List<List<Integer>> edges) {
        List<Integer> res = new ArrayList<>();
        int[] in = new int[n];
        for (List<Integer> list : edges) {
            in[list.get(1)]++;
        }
        for (int i = 0; i < n; i++) {
            if (in[i] == 0) res.add(i);
        }
        return res;
    }
}
